<template>
  <div class="view-list">
    <div
      class="list-item"
      v-for="(l,i) in homelist"
      :key="l.storyId"
      :class="{'none':i==0}"
      @click="pushroute(l.id, l.chapterId, l.chapterCount, l.author,l.img)"
      :style="{'background':l.story_color}"
    >
      <div class="item-view" v-if="i !==0" >
        <div class="title">{{ l.name }}</div>
        <span class="finish" v-if="l.chapterCount != 1 || l.is_serial == 1">{{
          l.is_serial == 1 ? "连载中" : "已完结"
        }}</span
        ><span class="total" v-if="l.chapterCount != 1 || l.is_serial == 1">{{
          "(更新至" + l.chapterCount + "集)"
        }}</span>
        <img v-lazy="l.img" class="lazyload-img" />
        <div
          class="desc"
          :class="[l.is_serial == 1 ? '' : l.chapterCount == 1 ? 'totop' : '']"
        >
          {{ l.summary }}
        </div>
        <div class="author">
          <img v-lazy="l.user_avatar" class="lazyload-img author-img" />
          {{ l.author }}
        </div>
      </div>
      <div class="has" v-if="i !==0">
        <div class="text" v-if="l.has_text == 1">文</div>
        <div class="audio" v-if="l.has_audio == 1">音</div>
        <div class="vedio" v-if="l.has_video == 1">视</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: null,
    };
  },
  components: {},
  props: {
    homelist: Array,
    routename: String,
  },
  methods: {
     pushroute(storyId, chapterId, count, author,img) {
      // if (this.routename == "home") {
      //   this.name = "";
      // } else {
        this.name = this.routename;
      // }
   sessionStorage.setItem('count',count)
      if (count == 1) {
        if (this.$route.name == `/${this.name}story/${this.name}content`) {
          this.$router.go(-1);
        } else {
          this.$router.push({
            name: `${this.name}content`,
          });
        }
        sessionStorage.contentList = JSON.stringify({
          id: chapterId,
          author: author,
        });
      } else {
        if (this.$route.name == `${this.name}/${this.name}story`) {
          this.$router.go(-1);
        } else {
          this.$router.push({
            name: `${this.name}story`,
          });
        }
        sessionStorage.storyList = JSON.stringify({
          id: storyId,
          route: this.name,
          img,
          count
        });
        // localStorage.routeList = JSON.stringify({

        // });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.view-list {
  position: fixed;
  display: flex;
  flex-wrap: wrap;
  justify-content:space-between;
  top: 55px;
  width: 100vw;
  height: 90vh;
  overflow: auto;
  //   background-color: red;
  .list-item {
    position: relative;
    width: 250px;
    height: 400px;
    margin-bottom: 20px;
   
    &.none{
        width: 0px;
        height: 0px;
        display: none;
    }

    // &::after {
    //   content: "";
    //   width: 100%;
    //   height: 70px;
    //   position: absolute;
    //   top: 4%;
    //   background-color: rgba(151, 135, 135, 0.1);
    // }
    img {
      width: 100%;
      height: 200px;
    
      z-index: -1;
    }
    .title {
      font-size: 14px;
      font-weight: 600;
      position: absolute;
      bottom: 41%;
      left: 6%;
      z-index: 800;
      color: rgb(247, 245, 245);
    }

    .finish {
      background-color: white;
      color: rgb(44, 120, 120);
      font-size: 12px;
      position: absolute;
      bottom: 32%;
      left: 6%;
      display: inline-block;
      border-radius: 10px;
      height: 15px;
      width: 50px;

      text-align: center;
      line-height: 15px;
      z-index: 800;
    }

    .total {
      position: absolute;
      bottom: 32.5%;
      left: 32%;
      font-size: 12px;
      color: rgb(220, 210, 210);
      z-index: 800;
    }
    .desc {
      position: absolute;
      bottom: 20%;
      box-sizing: border-box;
      left: 0;
      color: rgb(234, 216, 216);
      padding-left: 10px;
      padding-right: 10px;
      line-height: 20px;
      width: 100%;
      font-size: 8px;

      z-index: 800;

      &.totop {
        position: absolute;
        top: 20%;
      }
    }

    .author {
      position: absolute;
      bottom: 5%;
      left: 5%;
      color: rgb(216, 194, 194);

      .author-img {
        width: 30px;
        height: 30px;
        border-radius: 999px;
        vertical-align: middle;
      }
    }
    .has {
      position: absolute;
      bottom: 5%;
      right: 0;
      color: white;
      display: flex;
      flex-direction: column;
      height: 100px;

      div {
        flex: 1;
      }
    }
  }
}
</style>